﻿using System;
using System.Collections.Generic;
using DomainModel;
using Repository.Abstract;
using Services.Abstract;

namespace Services.Concrete
{
    public class GroupService : Service<Group>, IGroupService
    {
        private readonly IGroupRepository _groupRepository;

        public GroupService(IGroupRepository groupRepository)
            : base(groupRepository)
        {
            _groupRepository = groupRepository;
        }

        public Group Get(string name)
        {
            if (name == null || string.IsNullOrEmpty(name))
                throw new ArgumentNullException("name");

            return _groupRepository.GetByName(name);
        }

        /*public Group GetGroup(string name)
        {
            if (string.IsNullOrWhiteSpace(name))
                return null;

            return DAOFactory.DEFAULT.GroupDAO.GetByName(name);
        }

        public void Save(Group entity)
        {
            if (entity == null)
                return;

            if (string.IsNullOrWhiteSpace(entity.GroupName))
                return;

            if (this.GetGroup(entity.GroupName) == null)
            {
                DAOFactory.DEFAULT.GroupDAO.SaveOrUpdate(entity);
            }
        }

        public void Delete(Group entity)
        {
            if (entity != null)
                return;

            if (this.GetGroup(entity.GroupName) == null)
            {
                DAOFactory.DEFAULT.GroupDAO.Delete(entity);
            }
        }

        public Group GetById(long id)
        {
            if (id <= 0)
                return null;

            return DAOFactory.DEFAULT.GroupDAO.GetById(id);
        }

        public List<Group> GetAll()
        {
            return DAOFactory.DEFAULT.GroupDAO.GetAll().ToList();
        }*/
    }
}